// pages/course/course.js
const db=wx.cloud.database()
const swiperList = [
  `https://6a69-jia-2004-7gy5ewbi2ec368cd-1323896692.tcb.qcloud.la/非遗课程/1e0a5ba6700f0a7efc6c5ce7994e8da.jpg?sign=4a61039210f3846e4e3c8fe24f9d5d39&t=1730080473`,
  `https://6a69-jia-2004-7gy5ewbi2ec368cd-1323896692.tcb.qcloud.la/非遗课程/ca50220118e3e0bc55098de4de9e867.jpg?sign=21365c0afba53c8293cc1e98e88584ea&t=1730080487`,
  `https://6a69-jia-2004-7gy5ewbi2ec368cd-1323896692.tcb.qcloud.la/非遗课程/fbb2171b213e06f3b5d9a7055a0bf3b.jpg?sign=7a0174851c832063c9cb70b476fc738a&t=1730080493`
];
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 0,
    autoplay: true,
    duration: 500,
    interval: 3000,
    swiperList,
    value:"",
    imglist:"",
    imglist2:""
  },
  video(e){
  const id=e.currentTarget.dataset.id
  wx.navigateTo({
    url: '/packageA/pages/videodetail/videodetail?id='+id,
  })
  },

  tiaozhuan1(){
    wx.switchTab({
      url: '/pages/own/own',
    })
  },
  tiaozhuan2(){
    wx.navigateTo({
      url: '/packageA/pages/huodong/huodong',
    })
  },


//获取数据
getdata(){
  db.collection("course").get()
  .then(res=>{
    console.log(res);
    this.setData({
      imglist:res.data
    })
    })
    db.collection("cailiaobao").get()
    .then(res=>{
      console.log(res);
      this.setData({
        imglist2:res.data
      })
      })
},


//搜索框输入值
oninput(e) {
  // console.log(e.detail);
  console.log(e);
  this.setData({
    value: e.detail
  })

},
//跳转到搜索页面
onSearch() {
  
  wx.navigateTo({
    url: '/packageA/pages/search/search?key=' + this.data.value,
  })
  this.setData({
    value:""
  })
},


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getdata()
  },



  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})